﻿Partial Public Class ElencoNewsAdmin
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Page.Title = ConfigurationManager.AppSettings("sitename") & " Amministrazione - Gestione News"
    End Sub
    Private Sub GRD_News_DataRequesting(ByVal sender As Object, ByVal e As Trirand.Web.UI.WebControls.JQGridDataRequestEventArgs) Handles GRD_News.DataRequesting
        GRD_News.DataSource = (From n In DAL.Context.News Select n.ID, n.Titolo, n.Testo, n.DataPubblicazione, n.DataScadenza).ToList
    End Sub
    Private Sub GRD_News_RowDeleting(ByVal sender As Object, ByVal e As Trirand.Web.UI.WebControls.JQGridRowDeleteEventArgs) Handles GRD_News.RowDeleting
        Dim news As News = DAL.Context.News.Where(Function(n) n.ID.ToString = e.RowKey).Single
        If news IsNot Nothing Then
            DAL.Context.News.DeleteOnSubmit(news)
            DAL.Context.SubmitChanges()
        End If
    End Sub
End Class